package com.yiyun.blog.utils;

import com.yiyun.blog.dao.pojo.SysUser;

/**
 * @author Bao
 * @create 2022-03-05-20:42
 */
public class UserThreadLocal {

    //线程变量隔离
    private UserThreadLocal(){}

    //ThreadLocal：一个线程会有一个ThreadLocal，存储的是线程的信息（）
    private static final ThreadLocal<SysUser> LOCAL = new ThreadLocal<>();

    //存入用户信息
    public static void put(SysUser sysUser){

        LOCAL.set(sysUser);
    }
    //获取用户信息
    public static SysUser get(){
        return LOCAL.get();
    }
    //删除用户信息
    public static void remove(){
        LOCAL.remove();
    }
}
